<template>
  <div>
    <el-row>
      <el-menu :default-active="activeIndex" class="el-menu" mode="horizontal" @select="handleSelect">
        <el-col :span="4" :offset="4">
          <el-menu-item index="1">首页</el-menu-item>
        </el-col>
        <el-col :span="4">
          <el-menu-item index="2">公司简介</el-menu-item>
        </el-col>
        <el-col :span="4">
          <el-menu-item index="3">产品展示</el-menu-item>
        </el-col>
        <el-col :span="4">
          <el-menu-item index="4">联系我们</el-menu-item>
        </el-col>
        <el-col :span="4"></el-col>

        <!--<el-submenu index="2">
          <template slot="title">
            公司简介
          </template>
          <el-menu-item index="2-1">分类1</el-menu-item>
          <el-menu-item index="2-2">分类2</el-menu-item>
          <el-menu-item index="2-3">分类3</el-menu-item>
          <el-submenu index="2-4">
            <template slot="title">分类4</template>
            <el-menu-item index="2-4-1">产品4-1</el-menu-item>
            <el-menu-item index="2-4-2">产品4-2</el-menu-item>
            <el-menu-item index="2-4-3">产品4-3</el-menu-item>
          </el-submenu>
        </el-submenu>-->
      </el-menu>
    </el-row>
    <!--    <div class="line"></div>-->
  </div>
</template>

<script>
export default {
  name: 'header.vue',
  data () {
    return {
      activeIndex: '1'
    };
  },
  methods: {
    handleSelect (key, keyPath) {
      if (key !== this.activeIndex) {
        this.activeIndex = key;
        if (key === '1') {
          this.$router.push({ path: '/' });
        } else if (key === '2') {
          this.$router.push({ path: '/info' });
        } else if (key === '3') {
          this.$router.push({ path: '/products' });
        } else if (key === '4') {
          this.$router.push({ path: '/contact' });
        }
      }
      console.log(key, keyPath);
    }
  }
};
</script>

<style lang="stylus" scoped>
  .el-menu-item {
    padding: 0 62px;
    font-size: 16px;
    text-align center
  }

  /* 整体的下划线进行隐藏 */
  .el-menu.el-menu--horizontal {
    border-bottom: none;
  }
</style>
